package com.lei.applt.imglist;

import java.awt.Graphics;
import java.awt.Image;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.JPanel;

public class BackgroundImage extends JPanel{

	private  int width,height;
	private  Image img;
	
	private static final long serialVersionUID = 1L;

	public static void main(String[] args) throws UnsupportedEncodingException, IOException {
		String ws_url = "http://m.weather.com.cn/data5/city2103.xml";
		String str = "";
		
		URL url = new URL(ws_url);
		BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(),"utf-8"));
		StringBuffer sb = new StringBuffer();
		String s = "";
		
		while((s=br.readLine()) != null){
			sb.append(s + "\r\n");
		}
		br.close();
		str = new String(sb.toString().getBytes());
		
		
		String we = "http://m.weather.com.cn/data/{2103}.html";
		
	}
	
	public BackgroundImage(Image img,int width,int height){
		this.width = width;
		this.height = height;
		this.img = img;
		this.setBounds(0, 0, width, height);
		repaint();
	}
	
/*	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponents(g);
		g.drawImage(img, 0, 0, 500, 500, this);
	}*/
	
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		g.drawImage(img, 0, 0, width, height, this);
	}
}
